package com.whmnx.my.ui.viewmodel;

import androidx.annotation.NonNull;
import androidx.databinding.ObservableField;

import com.whmnx.base.bean.JiaoYiBean;
import com.whmnx.base.view.CommonDialog;
import com.whmnx.base.view.CommonDialog2;
import com.whmnx.my.R;
import com.whmnx.my.ui.fragment.MyOrderDetailsFragment;

import me.goldze.mvvmhabit.base.BaseViewModel;
import me.goldze.mvvmhabit.base.ItemViewModel;
import me.goldze.mvvmhabit.binding.command.BindingAction;
import me.goldze.mvvmhabit.binding.command.BindingCommand;

/**
 * author : huang
 * date   : 2020/9/15 0015 16:48
 * version: 1.0
 * @author Administrator
 */
public class InsideItemViewModel extends ItemViewModel {

    public ObservableField<JiaoYiBean.RecordListBean> entity = new ObservableField<>();

    //交易价格
    public ObservableField<String> Deal_Num = new ObservableField<>("");
    public ObservableField<String> Deal_Price = new ObservableField<>("");
    public ObservableField<String> Deal_StatusDesc = new ObservableField<>("");
    public InsideModel viewModel;


    public InsideItemViewModel(@NonNull InsideModel viewModel, JiaoYiBean.RecordListBean recordListBean) {
        super(viewModel);
        this.viewModel = viewModel;
        this.entity.set(recordListBean);
        Deal_Num.set("数量：" + recordListBean.getDeal_Num());
        Deal_Price.set("单价：￥" + recordListBean.getDeal_Price());
        Deal_StatusDesc.set(recordListBean.getDeal_StatusDesc());
    }

    //订单详情
    public BindingCommand  OnClickCommand = new BindingCommand(new BindingAction() {
        @Override
        public void call() {
            String s1,s2;
            if (Deal_StatusDesc.get().contains("售")) {
                 s1 = "出售提示";
                 s2 = "如您确认出售，点击【确认按钮】 后请耐心等待买家付款";
            }else {
                 s1 = "购买提示";
                 s2 = "如您确认购买，请前往【交易记录-播豆收购】给卖家付款";
            }
            new CommonDialog2(viewModel.fragment.getActivity(), R.style.dialog,s1, s2, (dialog, confirm) -> {
                if (confirm) {

                }
                dialog.dismiss();
            }).show();
        }
    });
}
